    <form action="" method="post" id="frmCompany"  name="frmCompany"> 	 	 	 	 	
        <div id="table-company">           
            <div class="header row">                
                <div class="col2 col">#</div>
                <div class="col3 col">Field Label</div>
                <div class="col4 col">Field Key</div>
                <div class="col5 col">Type</div>
                <div class="col4 col">Note</div>
                <div class="col6 col">Edit</div>
            </div>
            <?php
            $i = 1;
            if($_POST['btnSubmit']){
                $FieldLabel = esc_attr($_POST['FieldLabel']);
                $FieldKey = esc_attr($_POST['FieldKey']);
                $FieldType = esc_attr($_POST['FieldType']);
                $note = esc_attr($_POST['note']);
                if($_POST['hidID']<=0)
                    $sql = "INSERT INTO ".$wpdb->prefix."content_fields 
                            SET field_label='$FieldLabel',field_key='$FieldKey',field_type='$FieldType', note = '$note'";
                else
                     $sql = "UPDATE ".$wpdb->prefix."content_fields 
                                SET field_label='$FieldLabel',field_key='$FieldKey',field_type='$FieldType', note = '$note' 
                            WHERE id=".$_POST['hidID'];            
                $wpdb->query($sql);        
                wp_redirect_to('?page=accm_Site_Manager&tabmenu=fields');       
            }
            //---------------------------------------------------
            $sql = "SELECT * FROM ".$wpdb->prefix."content_fields";
            $db = $wpdb->get_results($sql);
            //user statsu 0: new -> user active -> 1, admin active -> 2
            foreach($db as $field) { ?>
            <div class="row">                
                <div class="col2 col"><?php print $i++;?></div>
                <div class="col3 col"><?php print $field->field_label;?></div>
                <div class="col4 col"><?php print $field->field_key;?></div>
                <div class="col5 col"><?php print $field->field_type;?></div>
                <div class="col4 col"><?php print $field->note;?></div>
                <div class="col6 col"><a href="?page=accm_Site_Manager&tabmenu=fields&act=update&type=fields&field_id=<?php print $field->id; ?>">Edit</a></div>
            </div>
             <?php } ?>
        </div>
        <div class="footer">            
            <input type="button" value="Add Field" id="btnAddField" name="btnAddField" class="button">
        </div>
    </form>
    <a name="field"></a>
<?php
       //update commnay       
       if(($_GET['act']=='update' && ($_GET['field_id'])) || $_GET['act']=='add') {
        
            $sql = "SELECT * FROM ".$wpdb->prefix."content_fields WHERE id=" . $_GET['field_id'] ;
            $db = $wpdb->get_row($sql);
            if($db) {
                $FieldLabel = trim($db->field_label);
                $FieldKey = trim($db->field_key);
                $FieldType = trim($db->field_type);
                $note = trim($db->note);
            }
        
        $options = array(
                "textfield" =>"Text Field",
                "textarea" =>"Textarea",
                "select" =>"Select",
                "selectlist" =>"Multi Select",
                "checkbox" =>"CheckBox Y/N",
                "radio" =>"Radio Y/N",
                'neighborhood' => 'Neighborhood',
                'subcategory' => 'Subcategory',
                'upload' => 'Upload File',
                'hotelregion' => 'HotelRegion',
                'cuisine' => 'Cuisine',
                'pricerange' => 'Price Range',
                'datetime' => 'Date time'
            );    
    ?>     
    <br clear=all /> 
    <h2>AddNew/Update Field</h2>
    <div class="wrap" id="register_user" style="width: 400px">     
        <form enctype="multipart/form-data" action="" method="post" name="frmField" id="frmField">	
            <table width="100%" cellspacing="5" cellpadding="0" border="0">
            <tbody><tr>
            	<td valign="top" align="left" colspan="2"> &nbsp;           	
               	</td>
            </tr>   
            
            <tr valign="top" width="100%"><td align="right" colspan="2"><i><font color="#bd0000">*</font> Indicates Required Information</i></td></tr>        
    		<tr><td colspan="2" class="formheader1">Field Information</td></tr>
            <tr valign="top" class="inputfield"><td align="right" style="width:28%;"><label><font color="#bd0000">*</font> Field Label:</label></td><td align="left" style="width:72%;">        	
                    	<input size="40" type="text" class="required" value="<?php print $FieldLabel;?>" name="FieldLabel" id="FieldLabel">                
                </td></tr>        
            <tr valign="top" class="inputfield"><td align="right" style="width:28%;"><label><font color="#bd0000">*</font> Field Key:</label></td><td align="left" style="width:72%;">        	
                    	<input size="40"  type="text" class="required" value="<?php print $FieldKey;?>" name="FieldKey" id="FieldKey">                
            	</td></tr>            
            <tr valign="top" class="inputfield"><td align="right" style="width:28%;"><label><font color="#bd0000">*</font>Field Type:</label></td><td align="left" style="width:72%;">        	
                    	<select id="FieldType" name="FieldType">
                            <option value="">--Select--</option>
                            <?php foreach($options as $key => $value) { ?>
                            <option value="<?php print $key;?>" <?php print ($FieldType==$key?"selected=selected":"");?>" >&nbsp;&nbsp;<?php print $value;?></option>
                            <?php } ?>
                        </select>             
            	</td></tr>
             <tr valign="top" class="inputfield"><td align="right" style="width:28%;"><label>Note:</label></td><td align="left" style="width:72%;">        	
                    	<textarea id="node" name="note" style="width:  100%;" rows="10"><?php print $note;?></textarea>                
            	</td></tr> 
             <tr valign="top" width="100%"><td valign="top" align="right" colspan="2">
             <input type="hidden" value="<?php print $_GET['field_id'];?>" id="hidID" name="hidID" />
			<input type="button" id="btnReset" name="btnResett" value="Reset"  class="button">&nbsp;&nbsp;<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit"  class="button">
            </td></tr>        
        </tbody></table>
        </form>
        
   </div>
<?php } ?>
 <script type="text/javascript">
        (function($){
            $(document).ready(function() {                
                 $('#btnAddField').click(function(){                        
                        window.location = "?page=accm_Site_Manager&tabmenu=<?php print $_GET['tabmenu'];?>&act=add#field";
                 });  
            });    
        })(jQuery);
     </script>